package UnitTest.DataStructureTest.stringANDlineTest.slidingWindowTest;

import DataStructure.stringANDline.slidingWindow.LNRSubstring;
import TestData.DataStructureTestData.stringANDlineTestData.slidingWindowTestData.LNRSubstringTestData;
import org.junit.Test;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * @author liujun
 * @author Email liujunfirst@outlook.com
 * @version 1.0
 * @date 2019-11-06 00:06
 * @description 单元测试： 最长无重复子串
 * 给定一个字符串，请你找出其中不含有重复字符的 最长子串 的长度。
 */

public class LNRSubstringTest extends LNRSubstringTestData {

    LNRSubstring lnrSubstring = new LNRSubstring();

    @Test
    public void testLNRSubstring() throws ClassNotFoundException, InvocationTargetException, IllegalAccessException {
        Class c = Class.forName("DataStructure.stringANDline.slidingWindow.LNRSubstring");
        Method[] m = c.getMethods();
        for (Method m1 : m) {
            if (m1.getName().contains("lengthOfLongestSubstring")) {
                int length = (int) m1.invoke(lnrSubstring, demo01);
                assert length == 3;
                length = (int) m1.invoke(lnrSubstring, demo02);
                assert length == 2;
                length = (int) m1.invoke(lnrSubstring, demo03);
                assert length == 9;

                length = (int) m1.invoke(lnrSubstring, demo04);
                assert length == 0;
                length = (int) m1.invoke(lnrSubstring, demo05);
                assert length == 0;
                length = (int) m1.invoke(lnrSubstring, demo06);
                assert length == 10;
                length = (int) m1.invoke(lnrSubstring, demo07);
                assert length == 8;
                length = (int) m1.invoke(lnrSubstring, demo08);
                assert length == 36;
                length = (int) m1.invoke(lnrSubstring, demo09);
                assert length == 1;
                length = (int) m1.invoke(lnrSubstring, demo10);
                assert length == 3;
                length = (int) m1.invoke(lnrSubstring, demo11);
                assert length == 16;
            }
        }
    }
}
